package com.dream.myqiyi.db;

import java.sql.SQLException;

import com.dream.myqiyi.dao.NoteResourceModel;
import com.dream.myqiyi.dao.NoteTagsModel;
import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

public class NoteResourceDaoImpl extends BaseDaoImpl<NoteResourceModel, String> implements NoteResourceDao {
	Dao<NoteResourceModel, String> noteResourceDao;
	
	public NoteResourceDaoImpl(ConnectionSource connectionSource) throws SQLException {
		super(connectionSource, NoteResourceModel.class);
	}
	
	public void performDBOperations(ConnectionSource connectionSource) throws SQLException {
		noteResourceDao = DaoManager.createDao(connectionSource, NoteResourceModel.class);
		
		// create table
		TableUtils.createTableIfNotExists(connectionSource, NoteResourceModel.class);
	}
	
	public Dao<NoteResourceModel, String> getDao() {
		return noteResourceDao;
	}

}
